﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AviumX.AviumCore.System.Threading
{
    class CPUThrottle
    {
        //Used to Overclock or set default OS speed.
        public static Boolean Enabled = false;
        public static int SecondTick = 0;
        public static int SecondMax = 1000000000;
        public static int Tick = 0;
        public static int FPS = 0;
        public static void SetSpeed(int s)
        {
            FPS = s * 10000000;
        }
        public static int GetSpeed()
        {
            return (int)FPS / 10000000;
        }
        public static Boolean Count()
        {
            if (Enabled == true)
            {
                if (SecondTick < SecondMax)
                {
                    SecondTick += 1;
                    if (Tick <= FPS)
                    {
                        Tick += 1;
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    SecondTick = 0;
                    Tick = 0;
                    return true;
                }
            }
            else
            {
                return true;
            }
        }
    }
}
